package org.sbbs.base.webapp.action;

import java.util.List;

import org.sbbs.base.pagequery.PagedQueryDao;
import org.sbbs.base.pagequery.hibernate.CustomCriteria;
import org.sbbs.base.pager.IPager;
import org.sbbs.base.pager.impl.JqgridPagerImpl;
import org.sbbs.base.searcher.SearchFilter;
import org.sbbs.base.searcher.SearchFilterBuilder;

/**
 * 一个分页action类只负责一个
 *
 * @author Administrator
 *
 */
public abstract class BaseJqgridPagedAction extends BaseAction {
	protected Integer page = 0;
	protected Integer total = 0;
	protected Integer records = 0;
	protected List pageList;

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public Integer getRecords() {
		return records;
	}

	public void setRecords(Integer records) {
		this.records = records;
	}

	public List getPageList() {
		return pageList;
	}

	public void setPageList(List pageList) {
		this.pageList = pageList;
	}

	/*protected PagedQueryDao hibernateCriteriaPagedQueryDao;

	public PagedQueryDao getHibernateCriteriaPagedQueryDao() {
		return hibernateCriteriaPagedQueryDao;
	}

	public void setHibernateCriteriaPagedQueryDao(
			PagedQueryDao hibernateCriteriaPagedQueryDao) {
		this.hibernateCriteriaPagedQueryDao = hibernateCriteriaPagedQueryDao;
	}*/

	/*public String gridPageList() {
		try {
			IPager pager = new JqgridPagerImpl(getRequest());
			SearchFilter sf = SearchFilterBuilder.buildSearchFilter(
					getRequest(), this.getSearchFilterType());
			if (this.getCustomCriteria() != null)
				pager = this.hibernateCriteriaPagedQueryDao.pagedQuery(this
						.getSearchEntityClazz(), pager, sf, this
						.getCustomCriteria());
			else
				pager = this.hibernateCriteriaPagedQueryDao.pagedQuery(this
						.getSearchEntityClazz(), pager, sf);

			this.pageList = pager.getList();
			records = pager.getTotalNumberOfRows();
			total = pager.getTotalNumberOfPages();
			page = pager.getPageNumber();
			this.processAfterQueried();
		} catch (Exception e) {
			log.error("GridList Error", e);
		}
		return SUCCESS;
	}*/
	public abstract String gridPageList();
	private int searchFilterType = SearchFilterBuilder.JQGRID_SELF;
	private Class searchEntityClazz;
	private CustomCriteria customCriteria;

	public int getSearchFilterType() {
		return this.searchFilterType;
	}

	public Class getSearchEntityClazz() {
		return this.searchEntityClazz;
	}

	public void setSearchFilterType(int searchFilterType) {
		this.searchFilterType = searchFilterType;
	}

	public void setSearchEntityClazz(Class searchEntityClazz) {
		this.searchEntityClazz = searchEntityClazz;
	}

	public CustomCriteria getCustomCriteria() {
		return customCriteria;
	}

	public void setCustomCriteria(CustomCriteria customCriteria) {
		this.customCriteria = customCriteria;
	}

	/*protected void processAfterQueried() {

	}*/
}
